<?php


namespace App\Http\Controllers\Api;


use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Request;

class BaseController extends Controller
{
    public function page()
    {

        try {
            Request::validate([
                'page'=>'integer',
                'limit'=>'integer'
            ]);
        }catch (\Exception $e){
            exit(json_encode([
                'code'=>-1,
                'data'=>null,
                'msg'=>"page,limit必须是整形",
            ],JSON_UNESCAPED_UNICODE));
        }
        $page= Request::get('page',1);
        $limit=Request::get('limit',10);
        if ($limit>50){
            $limit=50;
        }
        $offset=($page - 1)*$limit;
        return [$offset,$limit];
    }


}
